//
//  WDGoutReviewVehicleDetailViewModel.m
//  wd-serviceapp
//
//  Created by Bin Tang on 2025/2/11.
//

#import "WDGoutReviewVehicleDetailViewModel.h"

@implementation WDGoutReviewVehicleDetailViewModel
- (void)initialize {
    [super initialize];
    self.title = @"工单详情";
}

/// 获取详情
/// - Parameter completion: completion description
- (void)requestWithTaskInfoDetail:(RequestCompletionBlock)completion {
    @weakify(self);
    WDTaskInfoDetailRequest *request = [[WDTaskInfoDetailRequest alloc] initWithTaskId:@(self.serviceModel.id)];
    [request startWithCompletionBlockWithSuccess:^(__kindof TYZBaseRequest * _Nonnull request) {
        @strongify(self);
        EDSRespondDataEntity *respond = request.responseModelObject;
        if (respond.code == EDS_NETWORK_SUCCESS) {
            self.taskDetailModel = respond.data;
            
            UIFont *font = [UIFont systemFontOfSize:13 weight:UIFontWeightRegular];
            float width = kScreenW - 20 * 2 - 102;
            float height = [self.taskDetailModel.detail heightForFont:font width:width];
            height = (height > 18 ? height : 18);
            self.taskDetailModel.detailHeight = height;
            
            for (WDTaskFlowModel *ent in self.taskDetailModel.taskFlowList) {
//                ent.scanAddress = @"河南省洛阳市朱雀大街与长兴街交口北350M左路口";
                ent.scanAddressHeight = [ent.scanAddress heightForFont:font width:width] + 2;
                if (ent.scanAddressHeight < 18) {
                    ent.scanAddressHeight = 18;
                }
            }
            
            for (WDCanFaultInfoModel *ent in self.taskDetailModel.canFaultInfoList) {
                NSString *str = [NSDate timeStampWithString:ent.stimets format:@"yyyy-MM-dd HH:mm:ss"];
                ent.stimetsStr = str;
            }
            
//            self.taskDetailModel.vehicleAds = @"河南省洛阳市朱雀大街与长兴街交口北350M左路口";
//            self.taskDetailModel.vehicleAdsHeight = [self.taskDetailModel.vehicleAds heightForFont:font width:width] + 2;
//            if (self.taskDetailModel.vehicleAdsHeight < 18) {
//                self.taskDetailModel.vehicleAdsHeight = 18;
//            }
//            self.taskDetailModel.rescueAddress = @"河南省洛阳市朱雀大街与长兴街交口北350M左路口";
//            self.taskDetailModel.rescueAddressHeight = [self.taskDetailModel.rescueAddress heightForFont:font width:width] + 2;
//            self.taskDetailModel.rescueAddressHeight = (self.taskDetailModel.rescueAddressHeight > 18 ? self.taskDetailModel.rescueAddressHeight : 18);
//            
            
            
            /*
            NSMutableArray *addList = [NSMutableArray new];
            WDBatteryInfoModel *model = [WDBatteryInfoModel new];
            model.batteryTypeValue = @"卡里锂电池"; // 电池类型
            WDBatteryModelModel *ent1 = [WDBatteryModelModel new];
            model.batteryModel = ent1;
            ent1.modelNo = @"KT2424242";// 型号
            [addList addObject:model];
            [addList addObject:model];

            self.taskDetailModel.batteryList = addList.copy;
            */
            

        }
        [self sendResponseObject:request.responseModelObject completion:completion];
    } failure:^(__kindof TYZBaseRequest * _Nonnull request) {
        @strongify(self);
        [self sendResponseObject:request.responseModelObject completion:completion];
    }];
}

@end
